package cn.agiledata.bank.linkbank.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.vnv.infrastructure.action.IPBBaseAction;
import com.vnv.infrastructure.exception.IPBException;

public class CncbMockPayRequestAction extends IPBBaseAction {

    public int hasAccessPermission(int arg0, HttpServletRequest arg1)
            throws IPBException {
        return 1;
    }

    public ActionForward cncbMockPayRequest(ActionMapping mapping,
            ActionForm actionForm, HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        String SIGNMSG = (String) request.getParameter("SIGNMSG");
        String SHOPNO = SIGNMSG.substring(SIGNMSG.indexOf("<SHOPNO>") + 8,
                SIGNMSG.indexOf("</SHOPNO>"));
        String ORDERDATE = SIGNMSG.substring(
                SIGNMSG.indexOf("<ORDERDATE>") + 11, SIGNMSG
                        .indexOf("</ORDERDATE>"));
        String ORDERNO = SIGNMSG.substring(SIGNMSG.indexOf("<ORDERNO>") + 9,
                SIGNMSG.indexOf("</ORDERNO>"));
        String AMOUNT = SIGNMSG.substring(SIGNMSG.indexOf("<AMOUNT>") + 8,
                SIGNMSG.indexOf("</AMOUNT>"));

        StringBuffer RESPONSESIGNMSG = new StringBuffer();
        RESPONSESIGNMSG
                .append("<?xml version=\"1.0\" encoding=\"GB2312\"?><root><STATUS_ID>1</STATUS_ID>");
        RESPONSESIGNMSG.append("<SHOPNO>").append(SHOPNO).append("</SHOPNO>");
        RESPONSESIGNMSG.append("<ORDERDATE>").append(ORDERDATE).append(
                "</ORDERDATE>");
        RESPONSESIGNMSG.append("<ORDERNO>").append(ORDERNO)
                .append("</ORDERNO>");
        RESPONSESIGNMSG.append("<AMOUNT>").append(AMOUNT).append("</AMOUNT>");
        RESPONSESIGNMSG
                .append("<TRNO>71103102790011</TRNO><ACC_NO>4336********6483</ACC_NO><USER_NAME>张三</USER_NAME></root>");
        request.setAttribute("SIGNMSG", SHOPNO + "|"
                + RESPONSESIGNMSG.toString());
        return mapping.findForward("success");

    }
}
